using UnityEngine;

public class PlayerStateBehavior_Dribble_Stay : AbstractPlayerStateBehavior
{
	public static PlayerStateBehavior_Dribble_Stay instance;

	private PlayerStateBehavior_Dribble_Stay()
	{
	}

	public static PlayerStateBehavior_Dribble_Stay getInstance()
	{
		if (instance == null)
		{
			instance = new PlayerStateBehavior_Dribble_Stay();
		}
		return instance;
	}

	public override void enter(Player owner)
	{
		base.enter(owner);
	//	Instance<Court>.instance.tutorial.do_tutorial(TutorialType.Game_Move);
		if (owner.isUserRightHand)
		{
			owner.setMirrorAnimation();
		}
		else
		{
			owner.setNormalAnimation();
		}
		owner.getBallInHand();
		Instance<Ball>.instance.do_dribble_stay();
		if (Instance<Court>.instance.isInState(CourtStateFreeThrow.getInstance()) || Instance<Court>.instance.isInState(CourtStateBaseLine.getInstance()))
		{
			owner.playAnimation(AnimationName.player_dribble_stay, 1f, 0.5f);
		}
		else if (Random.Range(0, 2) == 0)
		{
			owner.playAnimation(AnimationName.player_dribble_stay2, 1.2f, 0.5f);
		}
		else
		{
			owner.playAnimation(AnimationName.player_dribble_stay3, 1f, 0.5f);
		}
	}

	public override void fixedUpdate(Player owner)
	{
		base.fixedUpdate(owner);
		if (!(owner.stateMachine.timeInState > 2f) || owner.IsPlayingAnimation(AnimationName.player_dribble_stay_back) || owner.IsPlayingAnimation(AnimationName.player_dribble_stay_crossleg) || Instance<Court>.instance.isInState(CourtStateFreeThrow.getInstance()))
		{
			return;
		}
		if (MathHelper.isInPercent(70f))
		{
			if (Random.Range(0, 2) == 0)
			{
				owner.playAnimation(AnimationName.player_dribble_stay_back, 1f, 0.8f);
			}
			else
			{
				owner.playAnimation(AnimationName.player_dribble_stay_crossleg, 1f, 0.8f);
			}
		}
		else
		{
			owner.stateMachine.timeInState = 0f;
		}
	}

	public override void exit(Player owner)
	{
		base.exit(owner);
		owner.setNormalAnimation();
	}
}
